from crawler_core.constant.constants import Constants
from down_server.impl.download_51job import Job51DownloadResume
from down_server.impl.download_boss import BossDownloadResume
from down_server.impl.download_dajie import DajieDownloadResume
from down_server.impl.download_hunter import HunterDownloadResume
from down_server.impl.download_lagou import LagouDownloadResume
from down_server.impl.download_zhaopin import ZhaopinDownloadResume


class DownloadProxy(object):
    def __init__(self):
        pass

    def download(self, context, cookies):

        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_51JOB:
            info = Job51DownloadResume()
            return info.download(context, cookies)
        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_LAGOU:
            info = LagouDownloadResume()
            return info.download(context, cookies)
        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_HUNTER:
            info = HunterDownloadResume()
            return info.download(context, cookies)
        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_DAJIE:
            info = DajieDownloadResume()
            return info.download(context, cookies)
        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_BOSS:
            info = BossDownloadResume()
            return info.download(context, cookies)
        if context[Constants.CONTEXT_TYPE] == Constants.CHANNEL_TYPE_ZHAOPIN:
            info = ZhaopinDownloadResume()
            return info.download(context, cookies)
